package com.surge;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {
	
	//该方法在 init 方法之后被调用
	public Object postProcessAfterInitialization(Object arg0, String arg1) throws BeansException {

		System.out.println("postProcessAfterInitialization..." + arg0 + "," + arg1);
		
		return arg0;
	}
	
	//该方法在 init 方法之前被调用
	//可以根据返回的对象来决定最终返回给 getBean 方法的对象是哪一个, 属性值是什么
	/**
	 * @param arg0: 实际要返回的对象
	 * @param arg1: bean 的 id 值
	 */
	public Object postProcessBeforeInitialization(Object arg0, String arg1) throws BeansException {
		
		System.out.println("postProcessBeforeInitialization..." + arg0 + "," + arg1);
		
		return arg0;
	}

}
